import { ApiProperty } from '@nestjs/swagger';
import { VerifyCodeType } from '../authorize.enum';
import {
  IsEmail,
  IsEnum,
  IsNotEmpty,
  IsOptional,
  IsPhoneNumber,
} from 'class-validator';

export class VerifyCodeDto {
  @ApiProperty({
    description: '验证码类型',
    enum: VerifyCodeType,
    example:
      '"LOGIN_WITH_EMAIL" | "LOGIN_WITH_PHONE" | "REGISTER_WITH_EMAIL" | "REGISTER_WITH_PHONE" | "RESET_PASSWORD_WITH_EMAIL" | "RESET_PASSWORD_WITH_PHONE" | "CHANGE_EMAIL" | "CHANGE_PHONE"',
    required: true,
  })
  @IsNotEmpty()
  @IsEnum(VerifyCodeType)
  verifyCodeType: keyof typeof VerifyCodeType;

  @IsOptional()
  @IsEmail({}, { message: 'Please enter a valid email address' })
  @ApiProperty({
    description: '邮箱',
    example: '1057****50@qq.com',
  })
  email: string;

  @IsOptional()
  @IsPhoneNumber('CN', { message: 'Please enter a valid phone number' })
  @ApiProperty({
    description: '手机',
    example: '182****4931',
  })
  phone: string;
}
